package team.pwy.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import team.pwy.consts.RbmConsts;
import team.pwy.mapper.CouponMapper;
import team.pwy.mapper.GoodsMapper;
import team.pwy.mapper.SeckillMapper;
import team.pwy.pojo.entity.Coupon;
import team.pwy.pojo.entity.Goods;
import team.pwy.pojo.entity.Seckill;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CouponServiceImpl implements CouponService {

    @Autowired
    private CouponMapper couponMapper;

    @Override
    public PageInfo<Coupon> findByUserId(Integer userId,Integer pageNum,Integer pageSize) {
        PageHelper.
                startPage(pageNum,pageSize);
        return new PageInfo<>(couponMapper.findByUserId(userId));
    }

    @Override
    public Integer delById(Integer id) {
        return couponMapper.delById(id);
    }

    @Override
    public PageInfo<Coupon> findByUserIdStatus(Integer userId, Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(couponMapper.findByUserIdStatus(userId, status));
    }


}
